﻿#ifndef _GEOMETRY_FIELD_H_H_
#define _GEOMETRY_FIELD_H_H_

#include "udatabase/interface/ifield.h"
#include "udatabase/interface/igeometryfield.h"
#include "udatabase/spatialDB/field.h"


namespace FD
{
	namespace Utility
	{
		namespace DB
		{
			///<summary>
			///几何字段构造类
			///包括几何字段属性信息的设置等
			///</summary>
			class FD_DB_Export CGeometryField : public FD::Utility::DB::Interface::IGeometryField
			{
				
			public:	
				///<summary>
				///析构函数
				///</summary>
				virtual ~CGeometryField();
			public:
				///<summary>
				///获取类型
				///</summary>
				///<param name=""></param>
				///<returns>类型</returns>
				virtual FD::Kernel::Geometry::Interface::GeometryType getGeometryType() const;
				///<summary>
				///设置类型
				///</summary>
				///<param name="type">类型</param>
				///<returns></returns>
				virtual void setGeometryType(FD::Kernel::Geometry::Interface::GeometryType type);
				///<summary>
				///获取空间参考
				///</summary>
				///<param name=""></param>
				///<returns>空间参考</returns>
				virtual const FD::Kernel::Math::SpatialReference* getSpatialReference() const;
				///<summary>
				///设置空间参考
				///</summary>
				///<param name="sr">空间参考</param>
				///<returns></returns>
				virtual void setSpatialReference(const FD::Kernel::Math::SpatialReference* ref_sr);

				/// <summary>
				/// 获取字段名称
				/// </summary>					
				/// <returns>字段名称</returns>
				virtual String getName() const;
				/// <summary>
				/// 获取字段别名
				/// </summary>					
				/// <returns>字段别名</returns>
				virtual String getAliasName() const;
				/// <summary>
				/// 获取字段类型
				/// </summary>
				/// <returns>字段类型</returns>
				virtual FD::Utility::DB::Interface::FieldType getFieldType() const;
				/// <summary>
				/// 获取字段大小，一般用于FD::Kernel::FdUnicodeString类型
				/// </summary>
				/// <returns>字段大小</returns>
				virtual UINT32 getSize() const;
				/// <summary>
				/// 获取字段精度，一般用于Real类型
				/// </summary>
				/// <returns>字段精度</returns>
				virtual UINT32 getPrecision() const;
				/// <summary>
				/// 获取字段描述
				/// </summary>
				/// <returns>字段描述</returns>
				virtual String getDescription() const;
				/// <summary>
				/// 判断是否必需字段
				/// </summary>
				/// <returns>是，返回true；否则，返回false</returns>
				virtual bool isRequest() const;
				/// <summary>
				/// 判断是否支持编辑，一般情况下，不允许编辑。
				/// </summary>
				/// <returns>是，返回true;否则，返回false</returns>
				virtual bool canEdit() const;
				/// <summary>
				/// 判断是否支持删除，一般情况下，必需字段不允许删除。
				/// </summary>
				/// <returns>是，返回true；否则，返回false</returns>
				virtual bool canDelete() const;
				/// <summary>
				/// 判断是否支持空值。
				/// </summary>
				/// <returns>是，返回true；否则，返回false</returns>
				virtual bool canNull() const;
				/// <summary>
				/// 设置字段别名
				/// </summary>
				/// <param name="value">字段别名</param>
				/// <returns></returns>
				virtual void setAliasName(const FD::Kernel::FdUnicodeString& name);
				/// <summary>
				/// 设置字段大小
				/// </summary>
				/// <param name="value">字段大小</param>					
				/// <returns></returns>
				virtual void setSize(UINT32 value);
				/// <summary>
				/// 设置字段精度
				/// </summary>
				/// <param name="value">字段精度</param>
				/// <returns></returns>
				virtual void setPrecision(UINT32 value);
				/// <summary>
				/// 设置字段描述
				/// </summary>
				/// <param name="description">字段描述</param>
				/// <returns></returns>
				virtual void setDescription(const FD::Kernel::FdUnicodeString& description);
				/// <summary>
				/// 深度拷贝
				/// </summary>
				/// <param name=""></param>
				/// <returns>拷贝对象</returns>
				virtual FD::Utility::DB::Interface::IField* clone() const;
				/// <summary>
				/// 设置字段名
				/// </summary>
				/// <param name="name">字段名</param>
				/// <returns></returns>
				virtual void setName(const FD::Kernel::FdUnicodeString& name);
				/// <summary>
				/// 设置字段是否可以为空
				/// </summary>
				/// <param name="value">是否</param>
				/// <returns></returns>
				virtual void setCanNull(bool value);
				/// <summary>
				/// 设置字段是否可以编辑
				/// </summary>
				/// <param name="value"></param>
				/// <returns></returns>
				virtual void setCanEdit(bool value);
				/// <summary>
				/// 设置字段是否可以被删除
				/// </summary>
				/// <param name="value"></param>
				/// <returns></returns>
				virtual void setCanDelete(bool value);
			public:
				//CGeometryField(FD::Kernel::IO::DataStream &stream);
				/// <summary>
				/// 序列化字段信息
				/// </summary>
				/// <param name="stream">流</param>
				/// <param name="hasHead">是否有头信息</param>
				/// <returns></returns>
				virtual void toStream(FD::Kernel::DataStream & stream,bool hasHead) const;
				///<summary>
				///构造函数
				///</summary>
				CGeometryField();
				///<summary>
				///拷贝构造函数
				///</summary>
				///<param name="geofield">几何体字段对象</param>
				///<returns></returns>
				CGeometryField(const CGeometryField &geofield);
			private:
				FD::Kernel::ref_ptr<FD::Kernel::Math::SpatialReference>			m_pSR;
				FD::Kernel::Geometry::Interface::GeometryType				m_type;
				FD::Utility::DB::Interface::IField						*m_field;

				friend class CFieldFactory;
			};
		}
	}
} //End of namespace

#endif 
